﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Reflection;
using System.Security.Policy;
using System.Collections;

namespace ModspaceDotNet
{
    namespace ConfigManagement
    {
        class Program
        {
            static void Main(string[] args)
            {

               /* System.Configuration.Configuration config =
                 ConfigurationManager.OpenExeConfiguration
                            (ConfigurationUserLevel.None);

                // Add an Application Setting.
                config.AppSettings.Settings.Add("ModificationDate",
                               DateTime.Now.ToLongTimeString() + " ");

                // Save the changes in App.config file.

                config.Save(ConfigurationSaveMode.Modified);
                */
                // Force a reload of a changed section.
                ConfigurationManager.RefreshSection("appSettings");
                foreach (string key in ConfigurationManager.AppSettings)
                {
                    string value = ConfigurationManager.AppSettings[key];
                    Console.WriteLine("Key: {0}, Value: {1}", key, value);
                }

                foreach (ConnectionStringSettings key in ConfigurationManager.ConnectionStrings)
                {
                    Console.WriteLine("ConKey: {0}, Value:{1}", key.Name, key.ConnectionString.ToString());

                }
                //Console.WriteLine(Environment.CurrentDirectory.ToString());

                //CheckAssembly();
            }
            static void CheckAssembly()
            {
                //Assembly asm = Assembly.LoadFile(@"\\fs11\42Documents\Interfaces\Plugins\ModspaceAiiTester.dll");
                Assembly asm = Assembly.LoadFile(@"c:\42-plugin-dev\ModspaceAiiTester\ModspaceAiiTester\bin\Debug\ModspaceAiiTesterAA.dll");
                DisplayAsmEvidence(asm);
            }
            private static void DisplayAsmEvidence(Assembly asm)
            {
                Evidence e = asm.Evidence;
                IEnumerator itfEnum = e.GetHostEnumerator();
                Console.WriteLine("****************");
                while (itfEnum.MoveNext()) {
                    
                    Console.WriteLine("Current Evidence: " +itfEnum.Current);
                    
                }
                Console.WriteLine("****************");
            }
        }
    }
}